package cn.czg.cms.controller;

import cn.czg.cms.common.ResultT;
import cn.czg.cms.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/profile")
public class ProfileController {

    @Autowired
    private FollowService followService;

    // 关注
    @PostMapping("/follow/{userId}")
    public ResultT<?> follow(@PathVariable Long userId) {
        followService.follow(userId);
        return ResultT.success("已关注");
    }

    // 取消关注
    @DeleteMapping("/follow/{userId}")
    public ResultT<?> unfollow(@PathVariable Long userId) {
        followService.unfollow(userId);
        return ResultT.success("已取消关注");

    }

    // 是否已关注
    @GetMapping("/follow/{userId}")
    public ResultT<Boolean> isFollowing(@PathVariable Long userId) {
        return ResultT.success(followService.isFollowing(userId));
    }

}
